import java.util.ArrayList;
import java.util.List;

class Solution {
    List<List<Integer>> ret;
    List<Integer> path;

    public List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();

        dfs(nums, 0);
        return ret;        
    }

    public void dfs(int[] nums, int pos){
        if(pos == nums.length){
            ret.add(new ArrayList<>(path));
            return ;
        }

        //选
        path.add(nums[pos]);
        dfs(nums, pos + 1);
        path.remove(path.size() - 1);  //回复现场
        //不选
        dfs(nums, pos + 1);
    }
}